package com.good.gpsapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import androidx.appcompat.widget.AppCompatTextView;

import java.util.List;

public class GnssAdapter extends BaseAdapter {

    private List<GnssInfo> data;
    private Context context;

    public GnssAdapter(Context context,List<GnssInfo> data){
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View viewRoot = LayoutInflater.from(context).inflate(R.layout.layout_item,null);
        AppCompatTextView tv_id = viewRoot.findViewById(R.id.tv_id);
        AppCompatTextView tv_country = viewRoot.findViewById(R.id.tv_country);
        AppCompatTextView tv_cf = viewRoot.findViewById(R.id.tv_cf);
        AppCompatTextView tv_cno = viewRoot.findViewById(R.id.tv_cno);
        AppCompatTextView tv_mark = viewRoot.findViewById(R.id.tv_mark);
        AppCompatTextView tv_hight = viewRoot.findViewById(R.id.tv_hight);
        AppCompatTextView tv_pos = viewRoot.findViewById(R.id.tv_pos);
        tv_id.setText(data.get(i).id);
        tv_country.setText(data.get(i).country);
        tv_cf.setText(data.get(i).cf);
        tv_cno.setText(data.get(i).cno);
        tv_mark.setText(data.get(i).mark);
        tv_hight.setText(data.get(i).elevation);
        tv_pos.setText(data.get(i).azimuth);
        return viewRoot;
    }
}
